package com.you.place.dal.dao;

import com.you.common.ibatis.AbstractDAO;
import com.you.place.dal.dao.dataobject.VoteDO;

public class VoteDAO extends AbstractDAO {

    public boolean create(VoteDO voteDO) {
        Long result = (Long) getSqlMapClientTemplate().insert("MS-INSERT-VOTE", voteDO);
        return result != null;
    }

    public VoteDO findUp(String fkType, Long fkId, Long memberId) {
        VoteDO voteDO = new VoteDO("up", fkType, fkId, memberId);
        return find(voteDO);
    }

    private VoteDO find(VoteDO voteDO) {
        return (VoteDO) getSqlMapClientTemplate().queryForObject("MS-SELECT-VOTE-BY-VOTE", voteDO);
    }

    public VoteDO findDown(String fkType, Long fkId, Long memberId) {
        VoteDO voteDO = new VoteDO("down", fkType, fkId, memberId);
        return find(voteDO);
    }

}
